<?php include("include.php");?>
<?php

$usersJobs = job::getJobByUserId($currentUser->getId());
$project = project::getProjectById($_GET['projectid']);
?>
<h1>Welcome to Your Dashboard</h1>
<div id="contentTopBar">
	<div id="title">Your Statistics</div>
	<table>
    	<tr>
        	<td>Job Completed<br /><span id="main">0</span></td>
            <td id="other">Job In Progress<br /><span>0</span></td>
            <td id="other">Total Jobs<br /><span><?php echo $usersJobs->num_rows;?></span></td>            
            <td id="other">Turn Around Time<br /><span>0.00</span></td>
        </tr>
    </table>
</div>
<?php errorCheck()?>
<div id="contentPane">
<div id="tableTitle"><a href="createJob.php?projectid=<?php echo $project->getId();?>"><img src="images/add-icon.png" /></a>Jobs</div>
<div class="list">
<table>

<tr>
	<th>Job ID</th>
    <th>Title</th>
    <th>Question</th>
    <th>Country</th>
    <th>Progress</th>
    <th>Category/Ext</th>
    <th>Edit</th>
    <th>Quarks</th>
    <th>Delete</th>
</tr>
<?php

while($row = $usersJobs->fetch_assoc()){
	$tempJob = new Job($row['id'],$row['user_id'],$row['project_id'],$row['title'],
				$row['description'],$row['country_id'],$row['ressource_type_id'],$row['ressource_ext_id'],
				$row['created_at'],$row['updated_at']);
	$num = $tempJob->getNumQuarkCompleted();
	$dem =  $tempJob->getNumQuark();
	if($dem != 0){
		$perc = ($num/$dem)*100;
	}else{
		$perc = 0;
	}
//go through every SQL row in the result set
	echo "<tr class=\"data\">";
		echo "<td>".$tempJob->getId()."</td>";
		echo "<td>".$tempJob->getTitle()."</td>";
		echo "<td>".$tempJob->getDescription()."</td>";
		echo "<td>".$tempJob->getCountry()->getShortName()."</td>";
		echo "<td>";
		proressBar($perc);
		echo "</td>";
		echo "<td>".$tempJob->getRessourceType()->getName()."/".$tempJob->getRessourceExt()->getName()."</td>";
		echo "<td><a href=\"editJob.php?jid=".$tempJob->getId()."\"><img src=\"images/edit-icon.png\"></a></td>";
		echo "<td><a href=\"jobQuarks.php?jid=".$tempJob->getId()."\"><img src=\"images/detail-icon.png\"></a></td>";		
		echo "<td><a href=\"deleteJobAction.php?jid=".$tempJob->getId()."\"><img src=\"images/delete-icon.png\"></a></td>";
	echo "</tr>\n";
	unset($tempJob);
}
?>
</table>
</div>
</div>
<?php include("includes/footer.php");?>